<html>
<head><meta charset="utf-8"><title>error handling patterns · project-error-handling · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/index.html">project-error-handling</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html">error handling patterns</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228004185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228004185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Gutoski <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228004185">(Feb 26 2021 at 22:17)</a>:</h4>
<p>Re-posting from <a class="stream" data-stream-id="122652" href="/#narrow/stream/122652-new-members">#new members</a> as advised:<br>
<span class="user-mention silent" data-user-id="392988">Gus Gutoski</span> <a href="#narrow/stream/122652-new-members/topic/error.20handling.20patterns/near/227998384">said</a>:</p>
<blockquote>
<p>Hi folks.  I'm new to Rust.  Building a cryptography library.  Looking for the right error handling pattern.  Found this zulip via <a class="stream" data-stream-id="257204" href="/#narrow/stream/257204-project-error-handling">#project-error-handling</a> .  It seems there's contention on how best to handle errors in Rust.  I found this article interesting <a href="https://sled.rs/errors">https://sled.rs/errors</a> .  Would someone be so kind as to refer me to the state-of-the-art on error handling patterns?  Thank you.</p>
</blockquote>



<a name="228004278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228004278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228004278">(Feb 26 2021 at 22:18)</a>:</h4>
<p>hello, happy to help</p>



<a name="228004317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228004317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228004317">(Feb 26 2021 at 22:18)</a>:</h4>
<p>rn we're still in early days working on a book documenting many of the best practices</p>



<a name="228004394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228004394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228004394">(Feb 26 2021 at 22:19)</a>:</h4>
<p>I did give a talk at rustconf that went over many of the basics <a href="https://www.youtube.com/watch?v=rAF8mLI0naQ">https://www.youtube.com/watch?v=rAF8mLI0naQ</a></p>
<div class="youtube-video message_inline_image"><a data-id="rAF8mLI0naQ" href="https://www.youtube.com/watch?v=rAF8mLI0naQ"><img src="https://i.ytimg.com/vi/rAF8mLI0naQ/default.jpg"></a></div>



<a name="228004407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228004407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Gutoski <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228004407">(Feb 26 2021 at 22:19)</a>:</h4>
<p>The book sounds interesting.</p>



<a name="228004449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228004449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Gutoski <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228004449">(Feb 26 2021 at 22:19)</a>:</h4>
<p>thanks for the link!  I'll definitely take a look</p>



<a name="228004547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228004547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228004547">(Feb 26 2021 at 22:20)</a>:</h4>
<p>my pleasure, if you have any additional questions lmk</p>



<a name="228022402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228022402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Gutoski <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228022402">(Feb 27 2021 at 01:31)</a>:</h4>
<p>Thanks for the video.  It's information dense with lots for me to chew on.  Do you have an opinion on the nested Result pattern described in the sled article?  <a href="https://sled.rs/errors">https://sled.rs/errors</a></p>



<a name="228023292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023292">(Feb 27 2021 at 01:42)</a>:</h4>
<p><span class="user-mention silent" data-user-id="392988">Gus Gutoski</span> <a href="#narrow/stream/257204-project-error-handling/topic/error.20handling.20patterns/near/228022402">said</a>:</p>
<blockquote>
<p>Thanks for the video.  It's information dense with lots for me to chew on.  Do you have an opinion on the nested Result pattern described in the sled article?  <a href="https://sled.rs/errors">https://sled.rs/errors</a></p>
</blockquote>
<p>I like it a lot</p>



<a name="228023300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023300">(Feb 27 2021 at 01:42)</a>:</h4>
<p>nested results are waaay better than 3 state result equivalents</p>



<a name="228023306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023306">(Feb 27 2021 at 01:43)</a>:</h4>
<p>something like</p>



<a name="228023319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023319">(Feb 27 2021 at 01:43)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">enum</span> <span class="nb">Result</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">E</span><span class="p">,</span><span class="w"> </span><span class="n">F</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="nb">Ok</span><span class="p">(</span><span class="n">T</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="nb">Err</span><span class="p">(</span><span class="n">E</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Fail</span><span class="p">(</span><span class="n">F</span><span class="p">),</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228023351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023351">(Feb 27 2021 at 01:44)</a>:</h4>
<p>which is how <code>nom</code> has handled non-recoverable parser errors in the past</p>



<a name="228023391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023391">(Feb 27 2021 at 01:44)</a>:</h4>
<p>not sure if they've updated that since</p>



<a name="228023413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023413">(Feb 27 2021 at 01:44)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">enum</span> <span class="nb">Err</span><span class="o">&lt;</span><span class="n">E</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Incomplete</span><span class="p">(</span><span class="n">Needed</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Error</span><span class="p">(</span><span class="n">E</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Failure</span><span class="p">(</span><span class="n">E</span><span class="p">),</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228023414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023414">(Feb 27 2021 at 01:44)</a>:</h4>
<p>looks like no</p>



<a name="228023438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023438">(Feb 27 2021 at 01:45)</a>:</h4>
<p>hmm</p>



<a name="228023441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023441">(Feb 27 2021 at 01:45)</a>:</h4>
<p>actually no</p>



<a name="228023447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023447">(Feb 27 2021 at 01:45)</a>:</h4>
<p>this is an error type</p>



<a name="228023460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/error%20handling%20patterns/near/228023460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/error.20handling.20patterns.html#228023460">(Feb 27 2021 at 01:45)</a>:</h4>
<p>im clearly misremembering things</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>